package com.Servlet;

import com.Service.Impl.ShoppingcarServiceImpl;
import com.Service.ShoppingcarService;
import com.entity.shoppingcar;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @Author: 冷俊杰
 * @Description: 查询购物车servlet
 * @DateTime: 2022/6/22 15:59
 **/
@WebServlet("/Shopping")
public class Shoppingcar extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ShoppingcarService service = new ShoppingcarServiceImpl();
        List<shoppingcar> shoppingcars = service.ListShoppingcar();
        System.out.println("结果" + shoppingcars);
        request.setAttribute("shoppingcars", shoppingcars);
        request.getRequestDispatcher("./cart.jsp").forward(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}